{extend name='common/common' /}

{block name="content"}
<el-row>
<el-col :md="12">
<el-card class="box-card">
	<div slot="header">
		<span class="span-primary"><i class="el-icon-date"></i></span>
		选择日报表日期
	</div>
	<div class="el-card-content">
		<el-form :model="form" :rules="rules" ref="form_ref" inline label-width="120px">
			<el-form-item label="报表日期" prop="rptDate">
				<el-date-picker type="date" placeholder="选择日报表日期"
					v-model="form.rptDate" value-format="timestamp">
				</el-date-picker>
			</el-form-item><br>
			<el-form-item label=" ">
				<el-button type="primary" @click="write" plain>上报</el-button>
			</el-form-item>
		</el-form>
	</div>
</el-card>
</el-col>
</el-row>
{/block}

{block name="script"}
<script type="text/javascript">
var main = new Vue({
	el:"#main",
	data:{
		loading:false,
		form:{
			rptDate:""
		},
		rules:{
			rptDate:[{required:true,message:'填报日期不能为空',trigger:['blur','change']}],
		}
	},
	methods:{
		write() {
			this.$refs['form_ref'].validate((valid) => {
				if(valid) {
					var param = {
						company_id:"{$Company.id}",
						rptDate:this.form.rptDate
					};
					$.post('{:url("Commit/Day_check")}',param,function(res){
						if(res.code == 1){
							var url = '{:url("Commit/Day")}?rptDate='+main.form.rptDate;
							window.location.href = url;
						}else{
							main.$notify.error({title:"错误",message:res.msg});
						}
					});
				}
			});
		}
	}
});
</script>
{/block}
